<template>
  <div class="basicInfo">
    <el-form :model="form" label-width="auto" style="max-width: 600px">
      <el-form-item label="账号名">
        <el-input :disabled="true" v-model.trim="basicData.user_name" />
      </el-form-item>

      <el-form-item label="所属角色">
       <el-input :disabled="true" v-model.trim="basicData.roles" />
      </el-form-item>

      <el-form-item label="创建时间">
        <el-input :disabled="true" v-model.trim="basicData.create_time" />
      </el-form-item>
    
    </el-form>
  </div>
</template>

<script setup>
import { onMounted, ref } from "vue"
import {getInfo} from "@/api/login"
import {parseTime,rolesName} from "@/utils/common"

const basicData=ref({
  user_name:"",
  roles:'', 
  create_time:""
})

// 获取基本信息
onMounted(()=>{
  getInfo().then(res=>{
    console.log(res);
    basicData.value.user_name=res.user.user_name
    basicData.value.create_time=parseTime(res.user.create_time,'{y}-{m}-{d} {h}:{i}')
    basicData.value.roles=res.user.roles.map(item => rolesName(item.name)).join('/')  
  })
})


// let arr=[
// {id: 3, name: '管理员', parent_name: 'A学院', stued: 2},
// {id: 3, name: '老师组', parent_name: 'A学院', stued: 2}

// ]
// str='管理员/老师组'
</script>

<style lang="scss" scoped>
.basicInfo{
  padding:50px 0 0 50px;
}
.el-input{
  width: 300px;
}
</style>